﻿@model List<PartyManagement.Models.UserProfile>

@{
    ViewBag.Title = "Members";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Add members</h2>
@using (Html.BeginForm("AddMember", "Group", FormMethod.Post))
{
    <table style="width: 600px;">
        <tr>
            <th style="width: 60%;">Member</th>
            <th style="width: 25%"></th>
            <th>
                <input type="checkbox" id="selectAll" /></th>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td style="width: 60%;">@item.UserName</td>
                <td style="text-align: center;">
                    <input type="checkbox" value="@item.UserId" class="chkId" name="chkID"/></td>
            </tr>
        }
    </table>
    <input type="submit" value="Add" />
}

<script>
    $("#selectAll").click(function () {
        var checked = $(this).is(':checked');
        $(".chkId").attr("checked", checked);
    });
    $(".chkId").click(function () {
        var valid = true;
        $(".chkId").each(function () {
            var checked = $(this).is(':checked');
            if (!checked) {
                valid = false;
            }
        });
        $("#selectAll").attr("checked", valid);
    });
</script>

<a href="javascript:history.go(-1)">Back</a>
